package com.activenetwork.smlite.testcase.login;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import com.activenetwork.smlite.page.LoginErrorPage;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.PageLoader;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Login005 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(Login005.class);

	@Test
	public void Username_special_characters_validation() {

		// user name has space
		loginBusiness.login("auto test1@activenetwork.com", "st@rc!te");
		LoginErrorPage loginErrorPage = PageLoader.load(LoginErrorPage.class);
		if(!StringUtils.equalsIgnoreCase(loginErrorPage.getErrorMsg(), "Username or Password is not correct.")){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					Login005.class.getName(), 
					"Verify user name has space", 
					"The error message is not correct."));
		}
		
		// user name has Chinese character
		loginBusiness.login("陈好", "password");
		loginErrorPage = PageLoader.load(LoginErrorPage.class);
		if(!StringUtils.equalsIgnoreCase(loginErrorPage.getErrorMsg(), "Username or Password is not correct.")){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					Login005.class.getName(), 
					"Verify user name has chinese character", 
					"The error message is not correct."));
		}
		
		// user name consists of special characters
		loginBusiness.login("!#$%*/?^`{|}~", "password");
		loginErrorPage = PageLoader.load(LoginErrorPage.class);
		if(!StringUtils.equalsIgnoreCase(loginErrorPage.getErrorMsg(), "Username or Password is not correct.")){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					Login005.class.getName(), 
					"Verify user name has special character", 
					"The error message is not correct."));
		}
		
		loginBusiness.logout();

	}

}
